package io.renren.modules.wx.dao;

import io.renren.modules.wx.entity.TestEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.wx.vo.BankQuestionVo;
import io.renren.modules.wx.vo.QuestionAndAnswerVo;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *
 *
 * @author linmingze
 * @email ${email}
 * @date 2022-10-21 09:49:34
 */
@Mapper
public interface TestDao extends BaseMapper<TestEntity> {

    List<BankQuestionVo> getQuestionsByTestId (@Param("testId") Integer testId);

    List<QuestionAndAnswerVo> getQuestionAndAnswer(@Param("studentId") Integer studentId, @Param("testId") Integer testId);

    @Select("select test_id from student_test_record where student_id = #{studentId}" )
    List<Integer> getTestIdsByStudentId(@Param("studentId") Integer studentId);

    @Insert("INSERT  into test_record (student_id,test_question_id,choice) values " +
            "(#{studentId},#{questionId},#{choice}) " )
    void insetToTestRecord(@Param("studentId") Integer studentId, @Param("questionId") Integer questionId,@Param("choice") Integer choice);

    @Insert("INSERT  into student_test_record (student_id,test_id) values " +
            "(#{studentId},#{testId}) " )
    void insetRecord(@Param("studentId") Integer studentId, @Param("testId") Integer testId);

    @Select("select id from  student_test_record where  student_id = #{studentId} and test_id = #{testId}" )
    List<Integer> getRecord(@Param("studentId") Integer studentId, @Param("testId") Integer testId);


}
